package org.apm.data.check;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apm.data.pusher.CommonMethod;
import org.elasticsearch.action.bulk.BulkProcessor;
import org.elasticsearch.client.Client;

public class SystemReIndex extends DataReIndex {
    private static final Logger LOGGER = LogManager.getLogger(JavaTraceDataReIndex.class);
    private static final String TYPE = "system";

    public SystemReIndex(Client client, BulkProcessor esBulkProcessor) {
        super(client, esBulkProcessor);
    }

    @Override
    protected boolean checkIndex(String index) {
        return index.contains(TYPE.toLowerCase());
    }

    @Override
    protected DataBean processData(String dataSource) {
        DataBean dataBean = new DataBean();
        dataBean.setSource(dataSource);
        dataBean.setFlag(true);
        return dataBean;
    }

    public static void main(String[] args) {
        DataReIndex dataReIndex = new SystemReIndex(CommonMethod.onlineClient(),
                CommonMethod.EsBulkProcessor.ONLINE.processor());
        dataReIndex.copyIndexData("apm2.0-guangdian-system-1-backup", "apm2.0-guangdian-system-1");
    }
}
